package cn.cxion.chat.app.adapter;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.google.zxing.common.StringUtils;
import com.lqr.optionitemview.OptionItemView;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import cn.cxion.chat.R;
import cn.cxion.chat.app.activity.ConstantActivity;
import cn.cxion.chat.app.bean.AppointmentInfo;
import cn.cxion.chat.app.bean.CheckContractBean;
import cn.cxion.chat.app.bean.SecBean;
import cn.cxion.chat.app.constant.Constant;
import cn.cxion.chat.app.util.LocalDisplay;
import cn.cxion.chat.app.util.LogUtil;
import cn.cxion.chat.app.util.StringUtil;
import cn.cxion.chat.app.view.ConstantItemView;

public class ConstantAdapter extends RecyclerView.Adapter<MyViewHolder> {


    private List<SecBean> secList;
    private CheckContractBean checkContractBean;
    private AppointmentInfo appointmentInfo;
    MyViewHolder holder;

    private Context context;

    public ConstantAdapter(Context context, List<SecBean> list) {
        this.context = context;
        if(list!=null)
        this.secList = list;
    }

    public AppointmentInfo getAppointmentInfo() {
        return appointmentInfo;
    }

    public void setAppointmentInfo(AppointmentInfo appointmentInfo) {
        this.appointmentInfo = appointmentInfo;
    }

    public CheckContractBean getCheckContractBean() {
        return checkContractBean;
    }

    public void setCheckContractBean(CheckContractBean checkContractBean) {
        this.checkContractBean = checkContractBean;
    }

    public List<SecBean> getSecList() {
        return secList;
    }

    public void setSecList(List<SecBean> secList) {
        this.secList = secList;
    }

    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        ConstantItemView itemView = new ConstantItemView(context);
        return new MyViewHolder(itemView.getView(),context);
    }

    @Override
    public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
        if(checkContractBean!=null)
            holder.setCheckContractBean(checkContractBean);
        else if(appointmentInfo!=null){
            holder.setAppointmentInfo(appointmentInfo);
        }
        holder.bindView(holder,secList.get(position));
        this.holder=holder;
    }

    public void rightClick(){
        holder.rightClick();
    }



    @Override
    public int getItemCount() {
        return secList == null ? 0 : secList.size();
    }



}
